package top.easycode.app.controller.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.easycode.app.common.BaseReq;
import top.easycode.app.common.BaseRsp;
import top.easycode.app.controller.APPBaseService;
import top.easycode.app.controller.service.dto.req.UserRegisterReq;
import top.easycode.app.controller.service.dto.rsp.UserInfoRsp;
import top.easycode.app.service.UserInfoService;
import top.easycode.app.util.DTOUtil;
import top.easycode.app.util.FlectUtil;

/**
 * Created by hujun on 2017\9\30 0030.
 */
@Service
public class UserRegisterService extends APPBaseService{
    @Autowired
    UserInfoService userInfoService;
    @Override
    protected BaseReq parseContext(String context, String type) throws Exception {
        UserRegisterReq userRegisterReq = DTOUtil.parseDTO(context,UserRegisterReq.class,type);
        return userRegisterReq;
    }

    @Override
    protected BaseRsp callPscService(BaseReq req, String... params) {
        UserRegisterReq registerReq = (UserRegisterReq)req;
        log.info("------------- 调用userRegister接口前参数-------------" + FlectUtil.getFiledsStr(registerReq));
        UserInfoRsp rsp =userInfoService.userRegister(registerReq.getName(),registerReq.getPassword()
                ,registerReq.getConfirmPassword(),registerReq.getNickname(),registerReq.getMobile(),registerReq.getHeadImage());
        log.info("------------- 调用userRegister接口后参数-------------" + FlectUtil.getFiledsStr(rsp));
        return rsp;
    }
}
